package cn.springcloud;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
import org.springframework.web.client.RestTemplate;

/**
 * @Author gc
 * @Date 2019/12/9 17:29  周一
 * @Description
 */
@SpringBootApplication
@EnableDiscoveryClient
@EnableRedisHttpSession
@EnableAsync
public class ConsumerApplication {

    /**
     * @LoadBalanced的作用是为RestTemplate 中添加拦截器，执行请求时在拦截器中实现负载均衡
     * @return
     */
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    public static void main(String[] args) {
        SpringApplication.run(ConsumerApplication.class, args);
        System.out.println("ConsumerApplication -->启动成功！！！！");
    }
}
